package io.github.talelin.sleeve.common.exception;
import io.github.talelin.sleeve.common.api.Code;
import org.springframework.http.HttpStatus;

public class FailedException extends HttpException {
    private static final long serialVersionUID = -661265124636854465L;
    protected int code;
    protected int httpCode;

    public FailedException() {
        super(Code.FAIL.getDescription(), Code.FAIL.getCode());
        this.code = Code.FAIL.getCode();
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
    }

    public FailedException(String message) {
        super(message);
        this.code = Code.FAIL.getCode();
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
    }

    public FailedException(int code) {
        super(Code.FAIL.getDescription(), code);
        this.code = Code.FAIL.getCode();
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = code;
    }

    public FailedException(String message, int code) {
        super(message, code);
        this.code = Code.FAIL.getCode();
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = code;
    }

    public int getCode() {
        return this.code;
    }

    public int getHttpCode() {
        return this.httpCode;
    }
}
